﻿using System;

namespace BurzaConsole
{
    public class Utils
    {
        public const int Second = 1;

        public const int Minute = 60;

        public const int Hour = 3600;

        private static DateTime _epoch = new DateTime(1970, 1, 1, 0, 0, 0);

        public static DateTime TimeStampToDateTime(int unixTimeStamp)
        {
            // Unix timestamp is seconds past epoch
            return _epoch.AddSeconds(unixTimeStamp).ToLocalTime();
        }

        public static int DateTimeToTimeStamp(DateTime dateTime)
        {
            var timeSpan = (dateTime.ToUniversalTime() - _epoch);
            return (int)timeSpan.TotalSeconds;
        }
    }
}